//go:build linux && arm

package sys

import (
	"os"
	"os/exec"
	"syscall"
)

func Daemonize(childArgs []string) (*exec.Cmd, error) {
	cmd := exec.Command(os.Args[0], childArgs...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Stdin = os.Stdin

	cmd.SysProcAttr = &syscall.SysProcAttr{
		Setsid: true,
	}

	err := cmd.Start()
	return cmd, err
}
